package cn.uyunsky.platform.data;

import com.alibaba.fastjson.JSON;

import java.util.Map;

public class UData {

    /**
     * 数据头
     */
	private UHead head;

    /**
     * 数据体
     */
	private Map<String,Object> body;

    /**
     * 数据JSON字符串
     */
    private String json;

	public UHead getHead() {
		return head;
	}

	public void setHead(UHead head) {
		this.head = head;
	}

	public Map<String,Object> getBody() {
		return body;
	}

	public void setBody(Map<String,Object> body) {
		this.body = body;
	}

    public String getJson() {
        return json;
    }

    public void setJson(String json) {
        this.json = json;
    }

    @Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("UData [head=");
		builder.append(head);
		builder.append(", body=");
		builder.append(formatString(body));
		builder.append("]");
		return builder.toString();
	}

    private static String formatString(Map<String, Object> map) {
        return JsonTool.formatJson(JSON.toJSONString(map), "  ");
    }
}
